package com.example.pet.controller;

import com.example.pet.beans.Category;
import com.example.pet.common.Result;
import com.example.pet.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author liukai
 * @version 1.0.0
 * @ClassName CategoryController.java
 * @Description TODO
 * @createTime 2021年04月23日 02:29:00
 */
@RestController
@RequestMapping(value = "/category")
public class CategoryController {

    @Autowired
    private ICategoryService iCategoryService;

    @GetMapping(value = "/getAllCategory")
    public Result getAllCategory() throws Exception {
        // 获取所有分类信息
        List<Category> allCategory = iCategoryService.findAllCategory();
        return Result.succ(allCategory);
    }

    /**
     * 获取分类图片
     * @param imgPath
     * @return
     */
    @GetMapping(value = "/getCategoryImg/{imgPath}")
    public ResponseEntity<byte[]> getCategoryImg(@PathVariable String imgPath) throws Exception {
        return iCategoryService.getCategoryImg(imgPath);
    }


}
